#ifndef POPUP_WINDOWS_THREAD_H
#define POPUP_WINDOWS_THREAD_H

#include <process.h>

struct Mutex
{
  CMutex m_mutex;
  CSingleLock m_lock;

  Mutex() : m_lock(&m_mutex, FALSE) {}
  virtual ~Mutex() {}

  int lock()   { return m_lock.Lock();   }
  int unlock() { return m_lock.Unlock(); }
};

struct PopupThread
{
  typedef void *(*ThreadRoutine)(void*);
  
  static int start(ThreadRoutine p_routine, void *p_args);

private:

  static void threadRoutineWrapper(void *p_args);
  
  struct WrapperArgs {
	
	ThreadRoutine m_routine;
	void *m_args;

	WrapperArgs(ThreadRoutine p_routine, void *p_args);
	virtual ~WrapperArgs() {}
	void run();
  };
};

#endif
